#include <iostream>
#include <vector>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 998244353;

ll ksm(ll a, ll b, ll m) {
	ll r = 1;
	a %= m;
	for (; b; b >>= 1, a = a * a % m)
		if (b & 1) r = r * a % m;
	return r;
}

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n + 1), cnt(n + 1);
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	ll ans = 0;
	for (int g = 1; g <= n; g++) {
		int c = 0;
		for (int j = g + g; j <= n; j += g) {
			c += cnt[j];
		}

		ans += ksm(2LL, c, MOD) * (ksm(2LL, cnt[g], MOD) - 1 + MOD) % MOD;
		ans %= MOD;
	}
	ans = (ksm(2LL, n, MOD) - 1 - ans) % MOD + MOD;
	ans %= MOD;
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

